using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;using Maxleaf.EDI.Domain.K3;

namespace Maxleaf.EDI.DataAccess.K3
{
    public class HRMS_TablesMap : EntityTypeConfiguration<HRMS_Tables>
    {
        public HRMS_TablesMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Name)
                .HasMaxLength(50);

            this.Property(t => t.sys_table_name)
                .HasMaxLength(50);

            this.Property(t => t.Description)
                .HasMaxLength(500);

            this.Property(t => t.Category)
                .HasMaxLength(50);

            this.Property(t => t.Name_Cht)
                .HasMaxLength(100);

            this.Property(t => t.Name_En)
                .HasMaxLength(100);

            this.Property(t => t.FOperatorIP)
                .HasMaxLength(50);

            this.Property(t => t.FOperatorHost)
                .HasMaxLength(30);

            // Table & Column Mappings
            this.ToTable("HRMS_Tables");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.sys_table_name).HasColumnName("sys_table_name");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.Built_in).HasColumnName("Built_in");
            this.Property(t => t.Category).HasColumnName("Category");
            this.Property(t => t.PrimaryKeyID).HasColumnName("PrimaryKeyID");
            this.Property(t => t.IsView).HasColumnName("IsView");
            this.Property(t => t.FSequence).HasColumnName("FSequence");
            this.Property(t => t.IsAllowAddNew).HasColumnName("IsAllowAddNew");
            this.Property(t => t.IsAllowEditField).HasColumnName("IsAllowEditField");
            this.Property(t => t.IsEditOption).HasColumnName("IsEditOption");
            this.Property(t => t.ViewStatus).HasColumnName("ViewStatus");
            this.Property(t => t.TableType).HasColumnName("TableType");
            this.Property(t => t.IsLocked).HasColumnName("IsLocked");
            this.Property(t => t.Name_Cht).HasColumnName("Name_Cht");
            this.Property(t => t.Name_En).HasColumnName("Name_En");
            this.Property(t => t.FIsSameStruct).HasColumnName("FIsSameStruct");
            this.Property(t => t.FIsFormulaUpdate).HasColumnName("FIsFormulaUpdate");
            this.Property(t => t.FOperator).HasColumnName("FOperator");
            this.Property(t => t.FOperatorIP).HasColumnName("FOperatorIP");
            this.Property(t => t.FOperateTime).HasColumnName("FOperateTime");
            this.Property(t => t.FOperatorHost).HasColumnName("FOperatorHost");

            // Relationships
            this.HasOptional(t => t.HRMS_Fields1)
                .WithMany(t => t.HRMS_Tables1)
                .HasForeignKey(d => d.PrimaryKeyID);

        }
    }
}
